package com.demo.snowflake;

import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
public class HutoolGenerate {
    public static void main(String[] args) {
        //参数1：workerId 终端ID
        //参数2：dataCenterId 数据中心id 指的是机房id
        Snowflake snowflake = IdUtil.createSnowflake(1, 1);
        long id = snowflake.nextId();
        System.out.println("雪花算法1（每次生成一个新对象）实现：" + id);

        Snowflake secondSnow = IdUtil.getSnowflake(1, 1);
        String secondId = secondSnow.nextIdStr();
        System.out.println("单例雪花算法2实现：" + secondId);
    }
}
